PROJECT(myproxy)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)

SET(CMAKE_C_COMPILER "gcc")

# ADD_DEFINITIONS(-DMY_MEM_NO_POOL)
# ADD_DEFINITIONS(-DMY_THREAD_MEM_NO_POOL)
# ADD_DEFINITIONS(-DMY_POOL_NO_PAGE)

IF(BUILD_TYPE STREQUAL "release")
   SET(C_FLAGS
      -Wall
      -Wextra
      -Werror
      -Wconversion
      -march=native
      -std=gnu11
      -O2
      -ggdb
      -fstack-protector
      --param=ssp-buffer-size=4
   )
ELSEIF(BUILD_TYPE STREQUAL "debug")
   SET(C_FLAGS
   -Wall
   -Wextra
   -Werror
   -Wconversion
   -march=native
   -std=gnu11
   -O0
   -ggdb
   -fstack-protector-all
   --param=ssp-buffer-size=4
   )
ELSE()
   SET(C_FLAGS
   -fsanitize=address
   -fno-omit-frame-pointer
   -Wall
   -Wextra
   -Werror
   -Wconversion
   -march=native
   -std=gnu11
   -O0
   -ggdb
   -fstack-protector-all
   --param=ssp-buffer-size=4
   )
ENDIF()

STRING(REPLACE ";" " " CMAKE_C_FLAGS "${C_FLAGS}")
MESSAGE(C_FLAGS ": " ${CMAKE_C_FLAGS})

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)
